package mymaggi.serienjunkiesmonitor;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class GetEpisodes {

	private static Logger logger = Logger.getRootLogger();
	private String quelltext;

	GetEpisodes(String quell){
		quelltext = quell;
	}
	
	public List<String> getEpisodes(){
		logger.debug("Episoden werden gesucht.");
		List<String> episodes = new ArrayList<String>();
		int addlen = 6;
		int currlen = 0;
		try{
			String[] split = quelltext.split("S..E..");
			while(true){
				for(int i=0;i<split.length;i++){
					currlen += split[i].length();
					String currEp = quelltext.substring(currlen, currlen+addlen);
					if(!episodes.contains(currEp))
						episodes.add(currEp);
					currlen += addlen;
				}
			}
		} catch (Exception e){
//			logger.error("Fehler: ", e);
		}
		logger.debug("Episoden wurden gesucht.");
		return episodes;
	}
}
